capture log close
set more off

log using table1&A1.log, replace text


****regenerate light variables for conveniency
gen light1990_cp=f101992_cp90
gen light1990_pref=f101992_pf
gen light1990_pfcp=f101992_pfcp

gen light1995_cp=f121995_cp90
gen light1995_pref=f121995_pf
gen light1995_pfcp=f121995_pfcp

gen light2000_cp=f152000_cp90
gen light2000_pref=f152000_pf
gen light2000_pfcp=f152000_pfcp

gen light2005_cp=f152005_cp90
gen light2005_pref=f152005_pf
gen light2005_pfcp=f152005_pfcp

gen light2010_cp=f162009_cp90
gen light2010_pref=f162009_pf
gen light2010_pfcp=f162009_pfcp

gen sampgdp = gdpsect2_1990_pfcp~=. & gdpsect2_2000_pfcp~=. & gdpsect2_2010_pfcp~=.
sum gdpsect2_1990_cp gdpsect2_2000_cp gdpsect2_2010_cp if D0==1
sum gdpsect2_1990_pfcp gdpsect2_2000_pfcp gdpsect2_2010_pfcp if D0==1
tab gdpsect2_1990_pref_impute if D0==1 & sampgdp==1


**************Table 1*****************************************

* 1990 Levels
gen D = 1
table D if D0==1, contents(mean censuspop1990_cp mean censuspop1990_pfcp) format(%15.0f)
table D if D0==1, contents(N censuspop1990_cp N censuspop1990_pfcp) format(%15.0f)

table D if D0==1 & sampgdp==1, contents(mean gdpsect2_1990_cp_df mean gdpsect2_1990_pfcp_df) format(%15.2f)
table D if D0==1 & sampgdp==1, contents(N gdpsect2_1990_cp_df N gdpsect2_1990_pfcp_df)

**** Distribution of GDP growth (which matches figure 1b)
gen grgdp1990_2010_cp = (gdpsect2_2010_cp_df-gdpsect2_1990_cp_df)/gdpsect2_1990_cp_df
gen grgdp1990_2010_pfcp = (gdpsect2_2010_pfcp_df-gdpsect2_1990_cp_df)/gdpsect2_1990_pfcp_df
sum grgdp1990_2010_cp if D0==1 & sampgdp==1, detail
sum grgdp1990_2010_pfcp if D0==1 & sampgdp==1, detail

foreach var in "censuspop" "light" {
  foreach unit in "cp" "pfcp" {
     
  egen sum_`var'1990_`unit'=sum(`var'1990_`unit') if D0==1
  egen sum_`var'2000_`unit'=sum(`var'2000_`unit') if D0==1
  egen sum_`var'2010_`unit'=sum(`var'2010_`unit') if D0==1

  gen gr_`var'9000_`unit'=(sum_`var'2000_`unit'-sum_`var'1990_`unit')/sum_`var'1990_`unit'
  gen gr_`var'0010_`unit'=(sum_`var'2010_`unit'-sum_`var'2000_`unit')/sum_`var'2000_`unit'
  gen gr_`var'9010_`unit'=(sum_`var'2010_`unit'-sum_`var'1990_`unit')/sum_`var'1990_`unit'
  
  }
}

*** Deflated GDP Sector 2
foreach var in "gdpsect2" {
  foreach unit in "cp_df" "pfcp_df" {
     
  egen sum_`var'1990_`unit'=sum(`var'_1990_`unit') if D0==1 & sampgdp==1
  egen sum_`var'2000_`unit'=sum(`var'_2000_`unit') if D0==1 & sampgdp==1
  egen sum_`var'2010_`unit'=sum(`var'_2010_`unit') if D0==1 & sampgdp==1

  gen gr_`var'9000_`unit'=(sum_`var'2000_`unit'-sum_`var'1990_`unit')/sum_`var'1990_`unit'
  gen gr_`var'0010_`unit'=(sum_`var'2010_`unit'-sum_`var'2000_`unit')/sum_`var'2000_`unit'
  gen gr_`var'9010_`unit'=(sum_`var'2010_`unit'-sum_`var'1990_`unit')/sum_`var'1990_`unit'
  
  }
}

*** Report Growth
tabstat gr_censuspop9000_cp gr_censuspop0010_cp gr_censuspop9010_cp if D0==1
tabstat gr_censuspop9000_pfcp gr_censuspop0010_pfcp gr_censuspop9010_pfcp if D0==1
tabstat gr_light9000_cp  gr_light0010_cp gr_light9010_cp if D0==1
tabstat gr_light9000_pfcp  gr_light0010_pfcp gr_light9010_pfcp if D0==1
tabstat gr_gdpsect29000_cp  gr_gdpsect20010_cp gr_gdpsect29010_cp if D0==1 & sampgdp==1
tabstat gr_gdpsect29000_pfcp  gr_gdpsect20010_pfcp gr_gdpsect29010_pfcp if D0==1 & sampgdp==1


*********** Table A1 ***************

#delimit ;
sum 
all_road_2010_rays all_road_1999_rays lall_road_2010_km_pfcp po_s_all_road_2010_ringxda rail_2010_rays lrail_2010_km_pfcp
road_1962_rays lroad_1962_km_pfcp po_s_road_1962_ringxda rail_1962_rays lrail_1962_km_pfcp ruralMigp00
D_censuspop9010_cp D_censuspop9010_pref D_gdpsect2_9010_cp D_emp9010_cp D_emp_man9010_cp D_manuempT9508_cp 
larea_cc90 larea_pf05 province_capitalPlus lcensuspop1982_pref frac_highedu1982_pref share_emp_man1982_pref lkm2coast sh_highedu1982_cppref sh_emp_man1982_cppref sh_pop1982_cppref
if D0==1, separator(0);
#delimit cr

log close
